package com.ce.pms.log4ce;

import java.util.Map;

import org.aspectj.lang.JoinPoint;

import com.ce.common.util.BlankUtil;
import com.ce.component.log4ce.aop.constructor.support.AbstractBizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.BizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.OriginalObjectHolder;
import com.ce.component.log4ce.aop.parser.BizLogParser;
import com.ce.pms.customer.vo.IndividualVO;
import com.ce.pms.customer.vo.OrganizationVO;

public class CustomerDeleteHandler extends AbstractBizDescriptionHandler implements BizDescriptionHandler
{
	@Override
	public Map<String, Object> getNamedParametersMap(JoinPoint joinPoint, Object returnValue, BizLogParser logParser)
	{
		Map<String,Object> map = logParser.getLogArguments(joinPoint);

		Object info = OriginalObjectHolder.ORIGINAL_OBJECTS.get().get("customerInfo");
		String houseNumber = (String) OriginalObjectHolder.ORIGINAL_OBJECTS.get().get("houseNumber");
		CustomerRecord record = null;
		if(!BlankUtil.isBlank(info) )
		{
			record = new CustomerRecord();
			record.setHouseNumber(houseNumber);
			if(info instanceof IndividualVO)
			{
				IndividualVO individualVO = (IndividualVO)info;
				record.setOwnerName(individualVO.getParticipantName() == null?"":individualVO.getParticipantName());
				record.setCertificateName(individualVO.getCertificateTypeName() == null?"":individualVO.getCertificateTypeName());
				record.setCertificateNo(individualVO.getCertificateNo() == null?"":individualVO.getCertificateNo());
				record.setTelephone(individualVO.getTelephone() == null?"":individualVO.getTelephone());
			}
			if(info instanceof OrganizationVO)
			{
				OrganizationVO organizationVO = (OrganizationVO)info;
				record.setOrganization(true);
				record.setOrgName(organizationVO.getParticipantName() == null ?"":organizationVO.getParticipantName());
				record.setOrgAddress(organizationVO.getAddress() == null?"":organizationVO.getAddress());
				record.setOrgTelephone(organizationVO.getTelephone() == null?"":organizationVO.getTelephone());
				record.setOrgContactPerson(organizationVO.getOrganizationLinkMan() == null?"":organizationVO.getOrganizationLinkMan());
				record.setOrgZipcode(organizationVO.getZip() == null?"":organizationVO.getZip());
			}

		}
		map.put("deleteOperationInfo", record.toString());
		map.putAll(logParser.getLogStaticContents(joinPoint));
		return map;
	}

}
